package com.dzl.util;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 *
 * @Project Name: AppMana
 * @File Name: DateUtil.java
 * @Package Name：com.yome.mana.utils
 * @Description: 日期工具类
 *
 * @Author：lujianmin ljm_3331@126.com
 * @Date：2015年5月12日 下午7:23:47
 * @Copyright 2015, 武汉由米定制科技有限公司 All rights reserved.
 * @version V1.0
 */
public class DateUtil {
	public static final int SECOND = 1000;
	public static final int MINUTE = SECOND * 60;
	public static final int HOUR = MINUTE * 60;
	public static final long DAY = HOUR * 24;
	public static final long WEEK = DAY * 7;
	public static final long YEAR = DAY * 356;

	final static public String FULL_ST_FORMAT = "yyyy-MM-dd HH:mm:ss";
	final static public String FULL_J_FORMAT = "yyyy/MM/dd HH:mm:ss";
	final static public String CURRENCY_ST_FORMAT = "yyyy-MM-dd HH:mm";
	final static public String CURRENCY_J_FORMAT = "yyyy/MM/dd HH:mm";
	final static public String DATA_FORMAT = "yyyyMMddHHmmss";
	final static public String ST_FORMAT = "yyyy-MM-dd HH:mm";
	final static public String ST_CN_FORMAT = "yyyy年MM月dd日 HH:mm";
	final static public String CN_FORMAT = "yy年MM月dd日HH:mm";
	final static public String YMD_FORMAT = "yyyy年MM月dd日";
	final static public String DAY_FORMAT = "yyyy-MM-dd";
	final static public String SHORT_DATE_FORMAT = "yy-MM-dd";
	final static public String YEAR_FORMAT = "yyyy";
	final static public String YEAR_MONTH = "yyyy-MM";
	final static public String YEAR_MONTH_SHORT = "yyyyMM";
	final static public String YEAR_MONTH_DAY_SHORT = "yyyyMMdd";

	public static String getDateTimeSequence() {
		SimpleDateFormat sdf = new SimpleDateFormat(DATA_FORMAT);
		return sdf.format(new Date());
	}

	public static String getDate(long second) {
		SimpleDateFormat sdf = new SimpleDateFormat(FULL_ST_FORMAT);
		return sdf.format(new Date(second));
	}

	public static String getToday() {
		SimpleDateFormat sdf = new SimpleDateFormat(DAY_FORMAT);
		return sdf.format(new Date());
	}

	public static String getNow() {
		SimpleDateFormat sdf = new SimpleDateFormat(FULL_ST_FORMAT);
		return sdf.format(new Date());
	}

	public static String getShortDate() {
		SimpleDateFormat sdf = new SimpleDateFormat(SHORT_DATE_FORMAT);
		return sdf.format(new Date());
	}

	public static String getYearMonth() {
		SimpleDateFormat sdf = new SimpleDateFormat(YEAR_MONTH);
		return sdf.format(new Date());
	}

	public static String getYearMonthDate(Date time) {
		SimpleDateFormat sdf = new SimpleDateFormat(YMD_FORMAT);
		return sdf.format(time);
	}

	public static String getYearMonthShort() {
		SimpleDateFormat sdf = new SimpleDateFormat(YEAR_MONTH_SHORT);
		return sdf.format(new Date());
	}

	public static String getYearMonthDayShort() {
		SimpleDateFormat sdf = new SimpleDateFormat(YEAR_MONTH_DAY_SHORT);
		return sdf.format(new Date());
	}

	public static String getYear() {
		SimpleDateFormat sdf = new SimpleDateFormat(YEAR_FORMAT);
		return sdf.format(new Date());
	}

	/**
	 *
	 * getIntervalMillis:获取两个时间相减的毫秒数
	 * @param time1
	 * @param time2
	 * @return
	 */
	public static long getIntervalMillis(String time1,String time2){
		SimpleDateFormat sdf=new SimpleDateFormat(FULL_ST_FORMAT);
		long t = 0;
		try {
			long date1 = sdf.parse(time1).getTime();
			long date2 = sdf.parse(time2).getTime();
			t = date1 - date2;
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return t > 0 ? t : 0;
	}

	/**
	 * 获取指定时间对应的毫秒数
	 * @param time "HH:mm:ss"
	 * @return
	 */
	public static long getTimeMillis(String time) {
	    try {
	        DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
	        DateFormat dayFormat = new SimpleDateFormat("yy-MM-dd");
	        Date curDate = dateFormat.parse(dayFormat.format(new Date()) + " " + time);
	        return curDate.getTime();
	    } catch (ParseException e) {
	        e.printStackTrace();
	    }
	    return 0;
	}

	/**
	 * 计算两个日期之间 的天数
	 *
	 * @param time1
	 * @param time2
	 * @return
	 * @throws ParseException
	 */
	public static long getQuot(String time1, String time2){
		long quot = 0;
		SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
		try {
			Date date1 = ft.parse(time1);
			Date date2 = ft.parse(time2);
			quot = date2.getTime() - date1.getTime();
			quot = quot / 1000 / 60 / 60 / 24;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return quot > 0 ? quot : 0;
	}

	/**
	 * 计算两个日期之间 相差多少天 多少小时多少分钟
	 *
	 * @param time1
	 * @param time2
	 * @return
	 * @throws ParseException
	 */
	public static String getExactQuot(String time1, String time2)
			throws ParseException {
		long timeOut = 0;// 时间差
		long days = 0;// 天数
		long hours = 0;// 小时
		long minutes = 0;// 分钟
	//	long seconds = 0;// 秒钟
		SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		try {
			Date date1 = ft.parse(time1);
			Date date2 = ft.parse(time2);
			timeOut = date1.getTime() - date2.getTime();
			days = timeOut / DAY;// 相差天数
			timeOut = timeOut % DAY;// 计算天数后剩余的毫秒数
			hours = timeOut / HOUR;// 计算相差的小时
			timeOut = timeOut % HOUR;// 计算小时候的毫秒数
			minutes = timeOut / MINUTE;// 计算相差的分钟
		} catch (Exception e) {
			e.printStackTrace();
		}
		return days + "天" + hours + "小时" + minutes + "分";
	}

	public static String getDatePoor(Date endDate, Date nowDate) {

		long nd = 1000 * 24 * 60 * 60;
		long nh = 1000 * 60 * 60;
		long nm = 1000 * 60;
		// long ns = 1000;
		// 获得两个时间的毫秒时间差异
		long diff = endDate.getTime() - nowDate.getTime();
		// 计算差多少天
		long day = diff / nd;
		// 计算差多少小时
		long hour = diff % nd / nh;
		// 计算差多少分钟
		long min = diff % nd % nh / nm;
		// 计算差多少秒//输出结果
		// long sec = diff % nd % nh % nm / ns;
		return day + "天" + hour + "小时" + min + "分钟";
	}

	public static String getExactQuots(String time2, String time1)//bbs时间差
			throws ParseException {
		long timeOut = 0;// 时间差
		long days = 0;// 天数
		long hours = 0;// 小时
		long minutes = 0;// 分钟
	//	long seconds = 0;// 秒钟
		SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		try {
			Date date1 = ft.parse(time1);
			Date date2 = ft.parse(time2);
			timeOut = date1.getTime() - date2.getTime();
			days = timeOut / DAY;// 相差天数
			timeOut = timeOut % DAY;// 计算天数后剩余的毫秒数
			hours = timeOut / HOUR;// 计算相差的小时
			timeOut = timeOut % HOUR;// 计算小时候的毫秒数
			minutes = timeOut / MINUTE;// 计算相差的分钟
		} catch (Exception e) {
			e.printStackTrace();
		}

		String s = null ;

		if( days > 0 ){
			s = days + "天前";
		}else{
			if( hours > 0 ){
				s =  hours + "小时前";
			}else{
				if( minutes > 0){
					s =  minutes + "分钟前";
				}
			}
		}

		return s;
	}


	/**
	 * 得到几天前的时间
	 * @param
	 * @return
	 */
	public static Date getOffsetDate(int offset) {
		Calendar now = Calendar.getInstance();
		now.setTime(new Date());
		now.add(Calendar.DATE, offset);
		return now.getTime();
	}

	/**
	 * 得到几周后的时间
	 * @param
	 * @return
	 */
	public static Date getOffsetWeek(int offset) {
		Calendar now = Calendar.getInstance();
		now.setTime(new Date());
		now.set(Calendar.DAY_OF_WEEK_IN_MONTH, now.get(Calendar.DAY_OF_WEEK_IN_MONTH) + offset);
		return now.getTime();
	}

	/**
	 * @param offset  -1表示向前 一年  1表示向后一年
	 * @return
	 */
	public static Date getOffsetYear(int offset) {
		Calendar now = Calendar.getInstance();
		now.setTime(new Date());
		now.add(Calendar.YEAR, offset);
		return now.getTime();
	}

	/**
	 * 获取年的开始
	 * @param date
	 * @return
	 */
	public static Date getYearBegin(Date date) {
		Calendar day = Calendar.getInstance();
		day.setTime(date);

		day.set(Calendar.MONTH, 0);
		day.set(Calendar.DAY_OF_MONTH, 1);
		day.set(Calendar.HOUR_OF_DAY, 0);
		day.set(Calendar.MINUTE, 0);
		day.set(Calendar.SECOND, 0);
		day.set(Calendar.MILLISECOND, 0);

		return day.getTime();
	}

	/**
	 * 获取年的开始
	 * @param
	 * @return
	 */
	public static Date getYearEnd(Date time) {
		Calendar date = Calendar.getInstance();
		date.setTime(time);

		date.add(Calendar.YEAR, 1);
		date.set(Calendar.MONTH, 0);
		date.set(Calendar.DAY_OF_MONTH, 1);
		date.set(Calendar.HOUR_OF_DAY, 0);
		date.set(Calendar.MINUTE, 0);
		date.set(Calendar.SECOND, 0);
		date.set(Calendar.MILLISECOND, 0);
		date.setTimeInMillis(date.getTimeInMillis() - 1);
		return date.getTime();
	}

	/**
	 * 将timestamp时间戳转换为string
	 */
	public static String parseTimeStamp(Timestamp real_time){
        String tsStr = "";
        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            tsStr = sdf.format(real_time);
            return tsStr;
        } catch (Exception e) {
            e.printStackTrace();
        }
		return "";
	}

	/**
	 * 将一个yyyy-MM-dd 字符串转化成date
	 * @param date
	 * @return
	 */
	public static Date parseDate(String date){
		SimpleDateFormat format = new SimpleDateFormat(DAY_FORMAT);
		try {
			return format.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 格式化日期
	 * @param date
	 * @return yyyy年MM月dd日
	 */
	public static Date parseDate2(String date){
		SimpleDateFormat format = new SimpleDateFormat(YMD_FORMAT);
		try {
			return format.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 将一个yyyy-MM-dd HH:mm:ss 字符串转化为date
	 * @param date
	 * @return
	 */
	public static Date parseDateTime(String date){
		SimpleDateFormat format = new SimpleDateFormat(FULL_ST_FORMAT);
		try {
			return format.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 格式化日期
	 * @param date
	 * @return yyyy-MM-dd HH:mm:ss
	 */
	public static String format2DateTime(Date date) {
		if (null == date) {
			throw new NullPointerException();
		}
		SimpleDateFormat format = new SimpleDateFormat(FULL_ST_FORMAT);
		return format.format(date);
	}

	/**
	 * 格式化日期
	 * @param date
	 * @return yyyy-MM-dd
	 */
	public static String format2Date(Date date) {
		if (null == date) {
			throw new NullPointerException();
		}
		SimpleDateFormat format = new SimpleDateFormat(DAY_FORMAT);
		return format.format(date);
	}

	/**
	 * 格式化日期
	 * @param date
	 * @return yyyy年MM月dd日
	 */
	public static String formatToDate(Date date) {
		if (null == date) {
			throw new NullPointerException();
		}
		SimpleDateFormat format = new SimpleDateFormat(YMD_FORMAT);
		return format.format(date);
	}

	/**
	 * 格式化日期
	 * @param date
	 * @return yyyy-MM
	 */
	public static String format2Month(Date date) {
		if (null == date) {
			throw new NullPointerException();
		}
		SimpleDateFormat format = new SimpleDateFormat(YEAR_MONTH);
		return format.format(date);
	}

	public static Date getDayBegin(Date date) {
		Calendar day = Calendar.getInstance();
		day.setTime(date);

		day.set(Calendar.HOUR_OF_DAY, 0);
		day.set(Calendar.MINUTE, 0);
		day.set(Calendar.SECOND, 0);
		day.set(Calendar.MILLISECOND, 0);

		return day.getTime();
	}

	/**
	 * 获取指定日期的开始时刻
	 * @param date  yyyy-MM-dd
	 * @return yyyy-MM-dd HH:mm:ss
	 * @throws ParseException
	 */
	public static Date getDayBegin(String date) {
		return getDayBegin(parseDate(date));
	}
	public static Date getDayBegin2(String date) {
		return getDayBegin(parseDate2(date));
	}

	/**
	 * 获取指定日期的开始时刻
	 * @param date
	 * @return
	 */
	public static Date getDayBegin(Long date) {
		return getDayBegin(new Date(date));
	}

	/**
	 * 获取今天的开始时刻
	 * @return
	 */
	public static Date getDayBegin() {
		return getDayBegin(new Date());
	}

	/**
	 * 获取指定日期的结束时刻
	 * @param date
	 * @return
	 */
	public static Date getDayEnd(Date date) {
		Calendar day = Calendar.getInstance();
		day.setTime(date);

		day.set(Calendar.HOUR_OF_DAY, 23);
		day.set(Calendar.MINUTE, 59);
		day.set(Calendar.SECOND, 59);
		day.set(Calendar.MILLISECOND, 999);

		return day.getTime();
	}

	/**
	 * 获取指定日期的结束时刻
	 * @param date yyyy-MM-dd
	 * @return
	 */
	public static Date getDayEnd(String date) {
		return getDayEnd(parseDate(date));
	}
	public static Date getDayEnd2(String date) {
		return getDayEnd(parseDate2(date));
	}

	/**
	 * 获取指定日期的结束时刻
	 * @param date
	 * @return
	 */
	public static Date getDayEnd(Long date) {
		return getDayEnd(new Date(date));
	}

	/**
	 * 获取今天的结束时刻
	 * @return
	 */
	public static Date getDayEnd() {
		return getDayEnd(new Date());
	}

	/**
	 * 获取指定日期所在周的周一开始时刻
	 * @param date
	 * @return
	 */
	public static Date getWeekBegin(Date date) {
		Calendar week = Calendar.getInstance();
		week.setTime(date);

		if (week.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {//周日是一周的开始,所以要将周日的时间设置成周六的,然后再计算周一
			Long time = week.getTime().getTime() - 1000 * 60 * 60 * 24;
			week.setTimeInMillis(time);
		}

		week.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
		week.set(Calendar.HOUR_OF_DAY, 0);
		week.set(Calendar.MINUTE, 0);
		week.set(Calendar.SECOND, 0);
		week.set(Calendar.MILLISECOND, 0);

		return week.getTime();
	}

	/**
	 * 获取指定日期所在周的周一开始时刻
	 * @param date
	 * @return
	 */
	public static Date getWeekBegin(String date) {
		return getWeekBegin(parseDateTime(date));
	}

	/**
	 * 获取指定日期所在周的周一开始时刻
	 * @param date
	 * @return
	 */
	public static Date getWeekBegin(Long date) {
		return getWeekBegin(new Date(date));
	}

	/**
	 * 获取今天所在周的周一开始时刻
	 * @return
	 */
	public static Date getWeekBegin() {
		return getWeekBegin(new Date());
	}

	/**
	 * 获取指定日期所在周的周日结束时刻
	 * @param date
	 * @return
	 */
	public static Date getWeekEnd(Date date) {
		Calendar week = Calendar.getInstance();
		week.setTime(date);

		if (week.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
			return getDayEnd(date);
		}

		week.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
		week.set(Calendar.HOUR_OF_DAY, 23);
		week.set(Calendar.MINUTE, 59);
		week.set(Calendar.SECOND, 59);
		week.set(Calendar.MILLISECOND, 999);
		week.setTimeInMillis(week.getTimeInMillis() + 1000 * 60 * 60 * 24);

		return week.getTime();
	}

	/**
	 * 获取指定日期所在周的周日结束时刻
	 * @param date
	 * @return
	 */
	public static Date getWeekEnd(String date) {
		return getWeekEnd(parseDateTime(date));
	}

	/**
	 * 获取指定日期所在周的周日结束时刻
	 * @param date
	 * @return
	 */
	public static Date getWeekEnd(Long date) {
		return getWeekEnd(new Date(date));
	}

	/**
	 * 获取今天所在周的周日结束时刻
	 * @return
	 */
	public static Date getWeekEnd() {
		return getWeekEnd(new Date());
	}

	/**
	 * 获取指定日期所在月的开始时刻
	 * @param date
	 * @return
	 */
	public static Date getMonthBegin(Date date) {
		Calendar month = Calendar.getInstance();
		month.setTime(date);

		month.set(Calendar.DAY_OF_MONTH, 1);
		month.set(Calendar.HOUR_OF_DAY, 0);
		month.set(Calendar.MINUTE, 0);
		month.set(Calendar.SECOND, 0);
		month.set(Calendar.MILLISECOND, 0);

		return month.getTime();
	}

	/**
	 * 获取指定日期所在月的开始时刻
	 * @param date
	 * @return
	 */
	public static Date getMonthBegin(String date) {
		return getMonthBegin(parseDate(date));
	}

	/**
	 * 获取指定日期所在月的开始时刻
	 * @param date
	 * @return
	 */
	public static Date getMonthBegin(Long date) {
		return getMonthBegin(new Date(date));
	}

	/**
	 * 获取今天所在月的开始时刻
	 * @param
	 * @return
	 */
	public static Date getMonthBegin() {
		return getMonthBegin(new Date());
	}

	/**
	 * 获取指定日期所在月的最后时刻
	 * @param date
	 * @return
	 */
	public static Date getMonthEnd(Date date) {
		Calendar month = Calendar.getInstance();
		month.setTime(date);
		month.add(Calendar.MONTH, 1);
		month.set(Calendar.DAY_OF_MONTH, 1);
		month.set(Calendar.HOUR_OF_DAY, 0);
		month.set(Calendar.MINUTE, 0);
		month.set(Calendar.SECOND, 0);
		month.set(Calendar.MILLISECOND, 0);
		month.setTimeInMillis(month.getTimeInMillis() - 1);

		return month.getTime();
	}

	/**
	 * 获取指定日期所在月的最后时刻
	 * @param date
	 * @return
	 */
	public static Date getMonthEnd(String date) {
		return getMonthEnd(parseDate(date));
	}

	/**
	 * 获取指定日期所在月的最后时刻
	 * @param date
	 * @return
	 */
	public static Date getMonthEnd(Long date) {
		return getMonthEnd(new Date(date));
	}

	/**
	 * 将月份格式的时间字符串转化为date
	 * @param month
	 * @return
	 */
	public static Date parse2Date(String month,String pattern){
		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
		try {
			return sdf.parse(month);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return  null ;
	}

	/**
	 * 获取今天所在月的最后时刻
	 * @param
	 * @return
	 */
	public static Date getMonthEnd() {
		return getMonthEnd(new Date());
	}


	public static List<String> getBetweenDates(String begin, String end) {
		if (begin.compareTo(end)>0) {
			return null;
		}

		List<String> result = new ArrayList<String>();

		SimpleDateFormat sdf = new SimpleDateFormat(DAY_FORMAT);//格式化为年月日
	    Calendar min = Calendar.getInstance();
	    Calendar max = Calendar.getInstance();

	    try {
	    	min.setTime(sdf.parse(begin));
	    	max.setTime(sdf.parse(end));
		} catch (ParseException e) {
			return null;
		}

	    Calendar curr = min;
	    while (curr.before(max)) {
	        result.add(sdf.format(curr.getTime()));
	        curr.add(Calendar.DAY_OF_YEAR, 1);
	    }
	    result.add(sdf.format(curr.getTime()));

	    return result;
	}

	/**
	 * 获取2个时间段之内的月份
	 * @param begin
	 * @param end
	 * @return
	 * @throws ParseException
	 */
	public static List<String> getBetweenMonth(String begin, String end) {
		if(begin.compareTo(end) > 0){
			return null;
		}

		ArrayList<String> result = new ArrayList<String>();
		SimpleDateFormat sdf = new SimpleDateFormat(YEAR_MONTH);//格式化为年月

		Calendar min = Calendar.getInstance();
		Calendar max = Calendar.getInstance();

		try {
			min.setTime(sdf.parse(begin));
			max.setTime(sdf.parse(end));
		} catch (ParseException e) {
			return null;
		}
		min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1);
		max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2);

		Calendar curr = min;
		while (curr.before(max)) {
			result.add(sdf.format(curr.getTime()));
			curr.add(Calendar.MONTH, 1);
		}

	    return result;
	}

	/**
	 * 获取某个月的今天
	 * @param offSet
	 * @return
	 */
	public static Date getOffsetMonth(int offSet) {
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
	    c.add(Calendar.MONTH, offSet);
	    return c.getTime();
	}

	/**
	 * 根据传入的Date和将来的day天，换算成时间戳，精确到秒
	 * @param date
	 * @param day
	 * @return
	 * @author liujiayi
	 */
	public static String getTimestamp(Date date,int day){
		Calendar c = Calendar.getInstance();
	    c.setTime(date);
	    c.add(Calendar.DAY_OF_MONTH, day);// 今天+day天
	    String timestamp = String.valueOf(c.getTimeInMillis()/1000);
		return timestamp;
	}

	/**
	 * 根据传入的Date换算和当前时间相差多少秒
	 * @param data
	 * @return
	 * @author liujiayi
	 */
	public static long getSubtractSec(Date data) {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date one = new Date();
        Date two = data;
        long day = 0;
        long hour = 0;
        long min = 0;
        long sec = 0;
        long ss = 0;
        try {
            two = df.parse("2018-10-16 12:00:00");
            long time1 = one.getTime();
            long time2 = two.getTime();
            long diff ;
            if(time1<time2) {
                diff = time2 - time1;
            } else {
                diff = time1 - time2;
            }
            day = diff / (24 * 60 * 60 * 1000);
            hour = (diff / (60 * 60 * 1000) - day * 24);
            min = ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60);
            sec = (diff/1000-day*24*60*60-hour*60*60-min*60);
            ss= (diff/1000-day*24*60*60);
            return ss;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
	}

	//计算两个日期相差年数
	  public static int yearDateDiff(Date date){
	     Calendar calBegin = Calendar.getInstance(); //获取日历实例
	     Calendar calEnd = Calendar.getInstance();
	     calBegin.setTime(date); //字符串按照指定格式转化为日期
	     calEnd.setTime(new Date());
	     return calEnd.get(Calendar.YEAR) - calBegin.get(Calendar.YEAR);
	  }

	/**
	 * 获取指定日期是星期几<br>
	 * @param date
	 * @return 指定日期是星期几
	 */
	public static String getWeekOfDate(Date date) {
		String[] weekDays = { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
		if (w < 0)
			w = 0;
		return weekDays[w];
	}

	/*public static void main(String[] args) {
		List<String> betweenMonth = getBetweenMonth("2017-09-02 0:12:11", "2017-10-01 0:22:11");
		System.out.println(betweenMonth);

		System.out.println(DateUtil.format2Date(new Date()));
		System.out.println(DateUtil.format2Date(DateUtil.getOffsetMonth(-12)));
		System.out.println(DateUtil.format2Date(getOffsetMonth(12)));
		System.out.println(DateUtil.format2Date(getOffsetMonth(-2)));
		System.out.println(DateUtil.format2Date(getOffsetMonth(-1)));
		System.out.println(DateUtil.format2Date(getOffsetMonth(0)));

		System.out.println("---");

		System.out.println(DateUtil.format2Date(getOffsetMonth(-2)));

		System.out.println(DateUtil.format2Date(getOffsetYear(-1)));

		System.out.println(DateUtil.format2Date(new Date()));
	}*/

	public static void main(String[] args) {
		//SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		//String aa = format.format("2019-03-20 11:59:05.0");
		//System.out.println(aa);
		//System.out.println(DateUtil.parseDateTime("2019-03-20 23:59:59"));

		long date =  DateUtil.getQuot("2021-11-13","2021-11-14");
		System.out.println(date);

	}
}
